package com.fast.api.home.controller;

import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Pointcut;
import org.springframework.stereotype.Component;

import java.util.Arrays;

/**
 * Class TestAspect
 *
 * @Auther: lhy
 * @Date: 2021/12/8 11:17
 * @Mail: 190643201@qq.com
 */
@Aspect
@Component
public class TestAspect {


    @Pointcut("@annotation(com.fast.api.home.controller.Test)")
    public void add() {

    }

    @Around("add()&&@annotation(test)")
    public Object advice(ProceedingJoinPoint joinPoint, Test test) throws Throwable {
        System.out.println(test.value());
        System.out.println(Arrays.toString(joinPoint.getArgs()));
        return joinPoint.proceed();//执行到这里开始走进来的方法体（必须声明）
    }

}
